﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;

namespace MVVMFramework.Core.Model
{
    public interface IDomainOperation : INotifyPropertyChanged
    {
        bool CanCancel { get; }
        Exception Error { get; }
        bool HasError { get; }
        bool IsCanceled { get; }
        bool IsComplete { get; }
        bool IsErrorHandled { get; }
        object UserState { get; }

        event EventHandler Completed;

        void Cancel();
        void MarkErrorAsHandled();
    }

    public interface ILoadOperation : IDomainOperation
    {
        IEnumerable AllEntities { get; }
        IEnumerable Entities { get; }
        ModelLoadBehavior LoadBehavior { get; }
        int TotalEntityCount { get; }
        IEnumerable<ValidationResult> ValidationErrors { get; }
    }

    public interface ILoadOperation<T> : ILoadOperation
    {
        new IEnumerable<T> Entities { get; }
    }

    public interface ISubmitOperation : IDomainOperation
    {
        IEntityChangeSet ChangeSet { get; }
        IEnumerable EntitiesInError { get; }
    }

    public interface IEntityChangeSet
    {
        IEnumerable AddedEntities { get; }
        IEnumerable ModifiedEntities { get; }
        IEnumerable RemovedEntities { get; }

        bool IsEmpty { get; }
    }

    /// <summary>
    /// I didn't really knew a better name...
    /// </summary>
    public enum ModelLoadBehavior
    {
        MergeIntoCurrent = 0,
        KeepCurrent = 1,
        RefreshCurrent = 2,
    }
}
